import {
  post,
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 course 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Reply {
  async getReplies() {
    const res = await get('v1/reply')
    return res
  }

  async getReply(id) {
    const res = await get(`v1/reply/${id}`)
    return res
  }

  async editText(info) {
    const res = await post('v1/text', info)
    return res
  }

  async getText(id) {
    const res = await get(`v1/text/${id}`)
    return res
  }

  async editPic(info) {
    const res = await post('v1/pic', info)
    return res
  }

  async getPic(id) {
    const res = await get(`v1/pic/${id}`)
    return res
  }

  async addReply(info) {
    const res = await post('v1/reply', info)
    return res
  }

  async editReply(info) {
    const res = await put('v1/reply', info)
    return res
  }

  async delectReply(info) {
    const res = await _delete('v1/reply', info)
    return res
  }
}

export default new Reply()
